<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <title>Document</title>
    <link rel="stylesheet" href="../../../public/dist/css/layui.css">
    <link rel="stylesheet" href="../../../css/salesgoods.css">
    <link rel="stylesheet" href="../../../public/font/iconfont.css">
</head>

<body>
    <!-- 查询 -->
    <div class="select">
        <div class="select-left">
            <!-- <div class="select-item">
                <div class="select-item-text">
                    客户名称
                </div>
                <input type="text" class="layui-input select-item-input">
            </div> -->

            <div class="select-item">
                <div class="select-item-text">
                    单号
                </div>
                <input type="text" class="layui-input select-item-input" id="a">
            </div>
            <div class="select-item">
                <div class="select-item-text">
                    订单状态
                </div>
                <select name="" id="b" class="select-item-select2 ">
                    <option value="">--请选择--</option>

                    <option value="40">未发货</option>
                    <option value="50">已发货</option>


                </select>
            </div>
            <!-- <div class="select-item">
                <div class="select-item-text">
                    日期
                </div>
                <input type="text" class="layui-input select-item-input" id="date">
            </div> -->
            <!-- 

           
                <div class="line"></div>
                <input type="text" class="layui-input select-item-input" id="date2">

                <select name="" id="" class="select-item-select">
                    <option value="">期间</option>
                    <option value="">期间</option>
                    <option value="">期间</option>

                </select>
            </div>

            <div class="select-item">
                <div class="select-item-text">
                    关键词
                </div>
                <input type="text" class="layui-input select-item-input">
            </div>

            <div class="select-item">
                <div class="select-item-text">
                    客户单号
                </div>
                <input type="text" class="layui-input select-item-input">
            </div>

            <div class="select-item">
                <div class="select-item-text">
                    部门
                </div>
                <select name="" id="" class="select-item-select2">
                    <option value=""></option>
                    <option value=""></option>
                    <option value=""></option>

                </select>
            </div>

            <div class="select-item">
                <div class="select-item-text">
                    制表人
                </div>
                <select name="" id="" class="select-item-select2">
                    <option value=""></option>
                    <option value=""></option>
                    <option value=""></option>

                </select>
            </div> -->

        </div>

        <div class="select-right">
            <div class="select-btn search">
                查询
            </div>
            <div class="select-btn reset">
                清除
            </div>
        </div>
    </div>


    <!-- 表单
    <div class="table">
        <div class="table-hand">
            <div class="tab">
                <div class="tab-item tab-item-this">全部</div>
                <div class="tab-item">未批</div>
                <div class="tab-item">已批</div>
                <div class="tab-item">退回</div>
                <div class="tab-item tab-item-right">作废</div>
            </div>
            <div class="hand">
                <div class="hand-item">
                    <span class="iconfont layui-icon-add-1"></span>
                    <i class="layui-icon layui-icon-add-1"></i> 
                    新增 
                </div>
                <div class="hand-item">
                    <i class="layui-icon layui-icon-delete"></i> 
                    删除 
                </div>
                <div class="hand-item">
                    <i class="layui-icon layui-icon-refresh"></i> 
                    刷新 
                </div>
                <div class="hand-item">
                    <i class="layui-icon layui-icon-edit"></i> 
                    审批 
                </div>
                <div class="hand-item">
                    <i class="layui-icon layui-icon-edit"></i> 
                    反审批 
                </div>
                <div class="hand-item">
                    <i class="layui-icon layui-icon-form"></i> 
                    打印 
                </div>
                <div class="hand-item">
                    <i class="layui-icon layui-icon-form"></i> 
                    打印设置 
                </div>
            </div>
        </div> -->

    <!-- <div class="table-content">
        <table class="layui-hide" id="test"></table>
    </div>
 -->

    <!-- <div class='page'>
        <div id="page"></div>
    </div> -->

    <div class="table-content">
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
    </div>
</body>

<!-- 头部 -->
<script type="text/html" id="toolbarinter">
    <div class="layui-btn-container ">
        <button class="layui-btn  layui-btn-sm colors  layui-bg-black" lay-event="check">发货</button>
        <!-- <button class="layui-btn  layui-btn-sm colors  layui-bg-black" lay-event="loss">审核不通过</button> -->
    </div>
</script>
    </div>
</body>
<script src="../../../public/dist/layui.js" charset="utf-8"></script>
<script src="../../../js/common/jquery.min.js"></script>
<script src="../../../js/common/api.js"></script>
<!-- <script src="../../../js/salesgoods.js" charset="utf-8"></script> -->






<script>
    layui.use(['table', 'laypage', 'laydate'], function () {
        var $ = layui.jquery;
        var table = layui.table;
        var laydate = layui.laydate;
        var laypage = layui.laypage
            , layer = layui.layer;
        //执行一个laydate实例
        laydate.render({
            elem: '#date' //指定元素
        });
        laydate.render({
            elem: '#date2' //指定元素
        });

        laypage.render({
            elem: 'page'
            , count: 100 //数据总数
        });

        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id),
                data = checkStatus.data; //获取选中的数据
            console.log(data)
            switch (obj.event) {
                case 'check':
                    var list = data[0];
                    if (list.transStatus == '40') {
                        var obj = {};
                            console.log(list)
                            obj.id = list.id;
                            obj.shipToId = list.recAddr;
                            console.log(obj)
                            handleAjax("coa/sellOrderShipments", obj, "POST").done(function(res){
                                console.log(res)
                            })
                            layer.msg('操作成功')
                            
                       
                    } else {
                        layer.msg('操作失败')
                    }
                    break;
            }
        });


        var tableIns = table.render({
            elem: "#test",
            url: base + "coa/getOrderList",
            method: "GET",
            where: {
                transStatus: '40'||'50',
                transType: "销售订单"
            },
            headers: {
                Authorization: "Bearer" + " " + sessions
            },
            request: {
                pageName: "currentPage",
                limitName: "pageSize"
            },
            toolbar: "#toolbarinter",
            limits: [10, 20],
            parseData: function (res) {
                //res 即为原始返回的数据
                console.log(res);
                return {
                    code: res.code, //解析接口状态
                    msg: res.message, //解析提示文本
                    totalNum: res.pageBean.totalNum, //解析数据长度
                    lists: res.pageBean.lists //解析数据列表
                };
            },
            response: {
                statusName: "code", //数据状态的字段名称，默认：code
                statusCode: 10000, //成功的状态码，默认：0
                msgName: "message", //状态信息的字段名称，默认：msg
                countName: "totalNum", //数据总数的字段名称，默认：count
                dataName: "lists" //数据列表的字段名称，默认：data
            },

            cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            page: {
                //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ["prev", "page", "next", "skip", "count"], //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                groups: 5, //只显示 1 个连续页码
                first: true, //不显示首页
                last: true, //不显示尾页
                prev: "上一页",
                next: "下一页",
                theme: "#c81623"
            },
            // height: 'full-20',//满高
            cols: [
                [{
                    type: 'checkbox',
                    fixed: "left",
                }, {
                    field: "createTime",
                    title: "创建时间",
                    minWidth: 120,
                    sort: true,
                    align: "center",
                    templet: function (d) {
                        var numv = null;
                        if (d.createTime == "" || d.createTime == null) {
                            numv = " ";
                        } else {
                            numv = d.createTime = layui.util.toDateString(
                                d.createTime,
                                "yyyy-MM-dd"
                            );
                        }
                        return numv;
                    }
                }, {
                    field: "transNo",
                    title: "订单单号",
                    minWidth: 110,
                    align: "center"
                }, {
                    field: "transDate",
                    title: "订单日期",
                    minWidth: 120,
                    sort: true,
                    align: "center",
                    templet: function (d) {
                        var numv = null;
                        if (d.transDate == "" || d.transDate == null) {
                            numv = " ";
                        } else {
                            numv = d.transDate = layui.util.toDateString(
                                d.transDate,
                                "yyyy-MM-dd"
                            );
                        }
                        return numv;
                    }
                }, {
                    field: "isLoan",
                    title: "收款方式",
                    minWidth: 140,
                    align: "center"
                }, {
                    field: "transStatus",
                    title: "收款状态",
                    minWidth: 200,
                    sort: true,
                    align: "center",
                    templet: function (d) {
                        var numv = null;
                        if (d.transStatus == "10") {
                            numv = "采购订单提交待审核";
                        }
                        else if (d.transStatus == "20") {
                            numv = "采购订单审核通过";
                        }
                        else if (d.transStatus == "15") {
                            numv = "采购订单审核不通过";
                        }
                        else if (d.transStatus == "30") {
                            numv = "采购订单待付款";
                        }
                        else if (d.transStatus == "35") {
                            numv = "销售订单审核不通过";
                        }
                        else if (d.transStatus == "40") {
                            numv = "销售订单待发货";
                        }
                        else if (d.transStatus == "50") {
                            numv = "销售订单已发货";
                        }
                        else if (d.transStatus == "60") {
                            numv = "采购订单收货";
                        }
                        else if (d.transStatus == "70") {
                            numv = "采购订单申请退货";
                        }
                        else if (d.transStatus == "80") {
                            numv = "采购方待退货";
                        }
                        else if (d.transStatus == "85") {
                            numv = "销售方不同意退货";
                        }
                        else if (d.transStatus == "90") {
                            numv = "采购退货";
                        }
                        else if (d.transStatus == "100") {
                            numv = "销售收获并退款";
                        }
                        return numv;
                    }
                }, {
                    field: "customerVendorName",
                    title: "客户简称",
                    minWidth: 100,
                    sort: true,
                    align: "center"
                }, {
                    field: "salesman",
                    title: "销售员名称",
                    minWidth: 100,
                    sort: true,
                    align: "center"
                }, {
                    field: "approved",
                    title: "批准",
                    minWidth: 100,
                    sort: true,
                    align: "center"
                }, {
                    field: "closed",
                    title: "关闭",
                    minWidth: 100,
                    sort: true,
                    align: "center"
                }, {
                    field: "estShipDate	",
                    title: "预交日",
                    minWidth: 120,
                    sort: true,
                    align: "center",
                    templet: function (d) {
                        var numv = null;
                        if (d.estShipDate == "" || d.estShipDate == null) {
                            numv = " ";
                        } else {
                            numv = d.estShipDate = layui.util.toDateString(
                                d.estShipDate,
                                "yyyy-MM-dd"
                            );
                        }
                        return numv;
                    }
                },

                {
                    field: "shipToId",
                    title: "发货地址",
                    minWidth: 100,
                    sort: true,
                    align: "center"
                }, {
                    field: "remark",
                    title: "备注",
                    minWidth: 100,
                    align: "center"
                }, {
                    field: "userName",
                    title: "制表人名称",
                    minWidth: 100,
                    align: "center"
                }, {
                    field: "editTime",
                    title: "单身数据",
                    minWidth: 80,
                    align: "center",
                    toolbar: '#barDemo'
                }, {
                    field: "editTime",
                    title: "修改时间",
                    minWidth: 130,
                    sort: true,
                    align: "center",
                    fixed: 'right',
                    templet: function (d) {
                        var numv = null;
                        if (d.editTime == "" || d.editTime == null) {
                            numv = " ";
                        } else {
                            numv = d.editTime = layui.util.toDateString(
                                d.editTime,
                                "yyyy-MM-dd"
                            );
                        }
                        return numv;
                    }
                },
                ]
            ]
        });


        
      

        /*查询*/
        $(".search").click(function () {
            if ($("#a").val() == "" && $("#b").val() == "") {
                layer.msg("请输入查询条件！", {
                    time: 1000,
                    offset: "t"
                });
                return;
            }

            var datelist = {
                transNo: $("#a").val(),
                transStatus: $("#b").val(),
                transType: "销售订单"
            };

            tableIns.reload({
                where: datelist,
                request: {
                    pageName: "currentPage", //页码的参数名称，默认：page
                    limitName: "pageSize" //每页数据量的参数名，默认：limit
                },
                page: {
                    curr: 1, //重新从第 1 页开始
                    layout: ["prev", "page", "next", "skip", "count"]
                }
            });
        });

        /*重置*/
        $(".reset").click(function () {
            $("#a").val("");
            $("#b").val("");
            tableIns.reload({
                where: {
                    transType: "销售订单"
                },
                page: {
                    curr: 1, //重新从第 1 页开始
                    layout: ["prev", "page", "next", "skip", "count"]
                }
            });
        });



    });
    //   table.render({
    //     elem: '#test'
    //     ,url:'/demo/table/user/'
    //     ,cols: [[
    //     {type:'checkbox'}
    //     ,{field:'id', title: '序号'}
    //     ,{field:'username', title: '操作'}
    //     ,{field:'sex', title: '	采购单号'}
    //     ,{field:'city', title: '采购日期'}
    //     ,{field:'sign', title: '付款方式'}
    //     ,{field:'experience', title: '单据类型名称'}
    //     ,{field:'score', title: '付款状态'}
    //     ,{field:'classify', title: '供应商名称	'}
    //     ,{field:'wealth', title: '采购员'}
    //     ]]
    //     ,page: true
    //   });



    // layui.use(['laypage', 'layer'], function(){
    //     var laypage = layui.laypage
    //     ,layer = layui.layer;

    //     //总页数低于页码总数
    //     laypage.render({
    //         elem: 'page'
    //         ,count: 50 //数据总数
    //     });
    // });
</script>

</html>